#include "exec_worker.h"
#include <QProcess>
#include <QStringListIterator>
#include <QDebug>

ExecWorker::ExecWorker(QObject *parent)
{
    this->selfP = parent;
}

void ExecWorker::doWork(QStringList cmd, QString metaStr)
{
    QProcess *poc = new QProcess(this->selfP);
    QStringList cmdList;
    cmdList << "/c";
    QStringListIterator strIterator(cmd);
    while (strIterator.hasNext())
        cmdList << strIterator.next();
    poc->start("cmd", cmdList);
    poc->waitForStarted();
    poc->waitForFinished(-1);
    QString res = QString::fromLocal8Bit(poc->readAllStandardError());
    emit onFinish(res, metaStr);
}
